package com.wang.interview.N03_stair;

import java.util.Scanner;

/**
 * @author: wang
 * @date: 2021/7/13 14:25
 * @description:
 */
public class ByArry {
    public static int f(int n){
        if ( n <= 0){
            throw new IllegalArgumentException(n+"参数不能小于等于0");
        }
        if ( n == 1 || n == 2){
            return n;
        }
        int i;
        int stepOne = 2;
        int stepTwo = 1;
        int temp;
        for (i = 2; i < n; i++){
            temp = stepOne;
            stepOne = stepOne+stepTwo;
            stepTwo = temp;
        }
        return stepOne;
    }
    public static void main(String[] args) {
        System.out.print("请输入一个大于0的整数：");
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        long i1 = System.currentTimeMillis();
        System.out.println(f(i));
        long i2 = System.currentTimeMillis();
        System.out.println(i2-i1);
        sc.close();
    }
}
